<template>
  <div class="block">
    <el-timeline>
      <el-timeline-item v-for="(item,index) of timeline" :key="index" :timestamp="item.bookontime" placement="top">
        <el-card>
          <p style="font-size: 16px">{{ item.bookname }}</p>
          <span>还书时间：{{ item.backtime }}</span>
        </el-card>
      </el-timeline-item>
    </el-timeline>
  </div>
</template>

<script>
import { history } from '@/api/user'

export default {
  data() {
    return {
      timeline: [
        {
          timestamp: '2018/4/20',
          title: '巨变',
          backtime: '2019/4/20 20:46'
        }
      ]
    }
  },
  created() {
    this.getHistory()
  },
  methods: {
    getHistory() {
      history().then(response => {
        this.timeline = response
      }).catch(error => {
        console.log(error)
      })
    }
  }
}
</script>
